#include "TLC5615.h"

void tlc5615_init() // init tlc5615
{
    DIN_0;
    SCLK_0;
    CS_1;
}
void tlc5615_set(uint16_t vol) // set voltage to tlc5615 [0,1023]
{
    uint8_t i;
    uint16_t temp;

    temp = vol << 6;

    CS_0;
    SCLK_0;
    for (i = 0; i < 12; i++)
    {
        if (temp & 0x8000)
            DIN_1;
        else
            DIN_0;
        SCLK_1;
        temp = temp << 1;
        SCLK_0;
    }
    CS_1;
}